Get the Current Date and Time in PHP

52

Get the Current Date and Time in PHP -

phpCopy<?php
$Object = new DateTime();  
$DateAndTime = $Object->format("d-m-Y h:i:s a");  
echo "The current date and time are $DateAndTime.";
?>

Get the Current Date and Time in PHP -

phpCopy<?php
$DateAndTime = date('m-d-Y h:i:s a', time());  
echo "The current date and time are $DateAndTime.";
?>

Comments

Submit
0 Comments